import Vue from 'vue'
import App from './App.vue'
import router from './router'
// import './plugins/element.js'
import './assets/css/global.css'
import './assets/fonts/iconfont.css'
import Axios from 'axios'
import TreeTable from 'vue-table-with-tree-grid'
// 树形表格要下载依赖插件
// 富文本编辑器安装依赖
import VueQuillEditor from 'vue-quill-editor'

// import 'quill/dist/quill.core.css' // import styles
// import 'quill/dist/quill.snow.css' // for snow theme
// import 'quill/dist/quill.bubble.css' // for bubble theme
// nprogress依赖
import Nprogress from 'nprogress'
// import 'nprogress/nprogress.css'
Vue.use(VueQuillEditor /* { default global options } */)
Vue.component('tree-table', TreeTable)

Vue.config.productionTip = false
Axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
Axios.interceptors.request.use(config => {
  config.headers.Authorization = sessionStorage.getItem('login_token')
  Nprogress.start()
  return config
})
Axios.interceptors.response.use(res => {
  Nprogress.done()
  return res
})
Vue.prototype.$http = Axios
Vue.filter(
  'timeFormat',
  // 可以将过滤器在main.js设置为全局，订单列表那里也用
  val => {
    const date = new Date(val * 1000)
    const Y = date.getFullYear()
    const M = (date.getMonth() + 1 + '').padStart(2, '0')
    const D = (date.getDate() + '').padStart(2, '0')
    const h = (date.getHours() + '').padStart(2, '0')
    const m = (date.getMinutes() + '').padStart(2, '0')
    const s = (date.getSeconds() + '').padStart(2, '0')
    return `${Y}-${M}-${D} ${h}:${m}:${s}`
  }
)
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
